<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<jsp:include page="common/header.jsp">
    <jsp:param name="title" value="${news.title} - 天天新闻网"/>
</jsp:include>

<!-- 页面主体内容 -->
<main class="container mt-4">
    <div class="news-detail">
        <!-- 新闻标题 -->
        <h1 class="news-title text-center mb-4">${news.title}</h1>
        
        <!-- 分享按钮 -->
        <div class="share-buttons text-center mb-4">
            <button class="btn btn-light btn-sm me-2"><i class="fab fa-weixin"></i> 微信</button>
            <button class="btn btn-light btn-sm me-2"><i class="fab fa-weibo"></i> 微博</button>
            <button class="btn btn-light btn-sm me-2"><i class="fas fa-link"></i> 复制链接</button>
            <button class="btn btn-light btn-sm"><i class="fas fa-share-alt"></i> 更多分享</button>
        </div>

        <!-- 新闻内容 -->
        <div class="news-content">
            <!-- 新闻元信息 -->
            <div class="news-meta text-muted mb-4">
                <span class="me-3"><i class="fas fa-user me-1"></i>${news.writer}</span>
                <span class="me-3"><i class="fas fa-clock me-1"></i>${news.newTime}</span>
            </div>

            <!-- 新闻正文 -->
            <div class="news-text">
                <c:set var="paragraphs" value="${fn:split(news.content, '。')}" />
                <c:set var="halfLength" value="${fn:length(paragraphs) / 2}" />
                
                <!-- 前半部分段落 -->
                <c:forEach items="${paragraphs}" var="paragraph" varStatus="status">
                    <c:if test="${status.index < halfLength && not empty paragraph}">
                        <p class="text-indent">${paragraph}。</p>
                    </c:if>
                </c:forEach>
                
                <!-- 新闻图片（如果有） -->
                <c:if test="${not empty news.img_url}">
                    <div class="news-image text-center my-4">
                        <img src="images/${news.img_url}" alt="" class="img-fluid rounded">
                    </div>
                </c:if>
                
                <!-- 后半部分段落 -->
                <c:forEach items="${paragraphs}" var="paragraph" varStatus="status">
                    <c:if test="${status.index >= halfLength && not empty paragraph}">
                        <p class="text-indent">${paragraph}。</p>
                    </c:if>
                </c:forEach>
            </div>
        </div>
    </div>
</main>

<jsp:include page="common/footer.jsp"/> 